<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/12
 * Time: 17:16
 */

namespace Modules\Api\Http\Controllers;

use Illuminate\Http\Request;
use Modules\Api\Service\UserService;
use Modules\SmallApi\Service\LogService;
class UserController extends BaseController
{

    /**
     *  获取用户的积分明细
     *  hinq 2019 11 12
     *
     **/
    public function integral_detail( Request $request ){
        $arr_input = (array) $request->all();
        $arr_list = UserService::integral_detail( (array) $arr_input );
        return response_json( $arr_list );
    }

    /**
     *	获取VIP会员等级
     *	hinq 2019 11 13
     *
     **/
    public function get_viplevel(){
        //获取所有vip等级
        $arr_list = UserService::get_vip_list();
        return response_json( $arr_list );
    }

    /**
     *  发送手机验证码接口
     *  hinq 2019 11 13
     *
     */
    public function send_phone_code( Request $request )
    {
        $s_phone = $request->get('phone',0);//登录表单信息
        $res = send_phone_code( $s_phone);

        $code = redis_phone_code( $s_phone );
        $arrLog['phone'] = $s_phone;
        $arrLog['code'] = $code;
        LogService::record_phone_code( (array) $arrLog );
        return $res;
    }

    /**
     *  修改手机号码
     *  hinq 2019 11 13
     *
     **/
    public function update_phone( Request $request ){
        $arrInput = (array) $request->all();
        $arr_list = UserService::update_one( (array) $arrInput );
        return response_json( $arr_list );
    }


    /**
     *  修改用户信息
     *  hinq 2019 12 09
     *
     **/
    public function update_info(  Request $request  ){
        $arr_input = (array)$request->all();
        $user = api_user();
        $arr_list = UserService::update_info( (array) $arr_input ,$user);
        return response_json( $arr_list );
    }

    public function user_viplist(){
        $arr_list = UserService::get_user_viplist();
        return response_json( $arr_list );
    }


    /**
     *  获取当前用户的详细信息
     *  hinq 2019 12 25
     *
     **/
    public function user_detail(){
        $arr_list = UserService::user_detail();
        return response_json( $arr_list );
    }


    /**
     *  获取指定用户的基本信息
     *  hinq 2020 4 20
     *  shop_id :  融云id
     **/
    public function user_info( Request $request ){
        $shop_id = (string) $request->get('shop_id');
        $arr_list = UserService::get_user_info( (string) $shop_id );
        return response_json( $arr_list );
    }

    /**
     *  通过id获取用户的get_rong_cloud_id
     *  hinq 2020 4 22
     *
     **/
    public function get_rong_cloud_id( Request $request ){
        $arr_input = (array) $request->all();
        $arr_list = UserService::get_rong_cloud_id( (array) $arr_input );
        return response_json( $arr_list );
    }



    /**
     *  同步用户分配的极光id  方便推送使用
     *  hinq 2020 5 13
     *
     **/
    public function sync_jpush_reg_id( Request $request ){
        $arr_input = (array) $request->all();
        return UserService::sync_jpush_reg_id( (array) $arr_input );
    }

    /**
     *  设置是否接收推送消息
     *  hinq 2020 5 19
     *
     **/
    public function user_jpush_set( Request $request ){
        $arr_input = (array) $request->all();
        return UserService::user_jpush_set( (array) $arr_input );
    }

    /**
     *   获取用户设置是否接收推送消息
     *   hinq 2020 5 19   
     *
     **/
    public function get_jpush_set(){
        return UserService::get_jpush_set();
    }
}